package OS.experiment12;

import javax.swing.*;
import java.awt.*;

public class UI {

    public static void main(String[] args){
        UI ui = new UI();
        ui.launch();
    }

    public void launch(){
        JFrame jFrame = new JFrame();
        jFrame.setTitle("主菜单");
        jFrame.setSize(300, 400);
        jFrame.setDefaultCloseOperation(3);
        jFrame.setLocationRelativeTo(null);

        GridLayout gridLayout = new GridLayout(6, 1);
        jFrame.setLayout(gridLayout);

        JButton create, block, wakeup, stop, show, schedule;
        create = new JButton("创建进程");
        block = new JButton("阻塞进程");
        wakeup = new JButton("唤醒进程");
        stop = new JButton("停止进程");
        show = new JButton("查看进程");
        schedule = new JButton("调度进程");

        jFrame.add(create);
        jFrame.add(block);
        jFrame.add(wakeup);
        jFrame.add(stop);
        jFrame.add(show);
        jFrame.add(schedule);

        //设置按钮监听器
        ButtonListener createListener = new ButtonListener(ButtonListener.CREATE);
        create.addActionListener(createListener);

        ButtonListener blockListener = new ButtonListener(ButtonListener.BLOCK);
        block.addActionListener(blockListener);

        ButtonListener wakeupListener = new ButtonListener(ButtonListener.WAKEUP);
        wakeup.addActionListener(wakeupListener);

        ButtonListener stopListener = new ButtonListener(ButtonListener.STOP);
        stop.addActionListener(stopListener);

        ButtonListener showListener = new ButtonListener(ButtonListener.SHOW);
        show.addActionListener(showListener);

        ButtonListener scheduleListener = new ButtonListener(ButtonListener.SCHEDULE);
        schedule.addActionListener(scheduleListener);

        jFrame.setVisible(true);
    }
}